import Vue from "vue";
import VueRouter from "vue-router";
import home  from "@/pages/home";
import discover from "@/pages/discover";


Vue.use(VueRouter);

//配置路由的步骤

//1.构建视图组件

//2.配置routes 一个path映射一个component

//3.router-view 配置视口

const routes = [
  {
    path: "/home",
    name: "home",
    props: true,
    component: home,
  },
  {
    path: "/discover",
    component: discover,
    //重定向
    // redirect: "/discover/DJradio",
    children:[
      {
        path: "DJradio",
        name: "djradio",
        // component:()=>import(/*webpackChunkName:'DJradio'*/'@/pages/discover/DJradio')
        components: {
          djradio: ()=>import(/*webpackChunkName:'djradio'*/'@/pages/discover/DJradio'),
          toplist:()=>import(/*webpackChunkName:'toplist'*/'@/pages/discover/Toplist')
        }   
      },
      {
        path: "Toplist",
        name: "toplist",
        component:()=>import(/*webpackChunkName:'Toplist'*/'@/pages/discover/Toplist')
      }
    ]
  },
  {
    path: "/friend",
    //路由懒加载
    //将代码切割，加快首屏渲染速度
    component: ()=>import(/*webpackChunkName:'friend'*/'@/pages/friend')
  },
  {
    path: "/goods",
    component: ()=>import(/*webpackChunkName:'goods'*/'@/pages/goods')
  },
  {
    path:"/details/:id",
    props: true,
    component:()=>import(/*webpackChunkName:'details'*/'@/pages/details')
  },
  {
    path:"*",
    component:()=>import(/*webpackChunkName:'index'*/'@/pages/page404')
  },
  {
    path:"/count",
    component:()=>import(/*webpackChunkName:'count'*/'@/pages/count')
  },
  {
    path:"/",
    redirect:"/Shopping"
  },
  {
    path:"/Shopping",
    component:()=>import(/*webpackChunkName:'Shopping'*/'@/pages/Shopping')
  }
];


export default new VueRouter({
  routes,
});